VXFORM1 4vxBase Sample Application: Aircraft Brokerage System Form1 Picture1 DDDK0 DKDK0 DKDK0 Label1 vxBase Sample Application Tms Rmn FileMenu &File s OpenTypes &Types OpenCust &Customers OpenAircraft &Aircraft SepBar ExitCode LinkMenu &Link LinkBuyToSell &Buyer to Sellers LinkSellToBuy &Seller to Buyers { MaintMenu &Maintenance | PackFiles &Pack TestMenu &Test TestCreate &Create TestCopy Copy &Structure TestDataCopy Copy &Data FileStruc &File Structure Label1_Click\ FileOpen_Click DbfRef/ vxUseDbf NtxRefJ vxUseNtxZ FALSE vxCloseAll vxTopu Text1 textm Text2| vxRecNo Text3 vxDouble8 Command1_Clickg vxSkip vxEof Command2_ClickY ExitCode_Click RecNo TRUEh CurrVc FldName. CurrAmtx EndFi DbfArea SkipCommand_Click> Text4 vxField FileBrowse_Click vxBrowse BrowseRet5 Text5m VXFORM1P hWndD BROWSE_CLOSED BROWSE_EDIT BROWSE_ADD~ BROWSE_DELETE Enabled BROWSE_ERROR BrowseActiveS Form_Clickr Label16 Caption FileJoin_Click Cluser CluserNtx? ClprodJ ClprodNtxK TableDeclare ColorRef% VX_RED1 TableField VX_FIELD TabelFieldr VX_BLUEC vxSelectDbf vxSelectNtx vxJoin vxTableDeclareK vxTableField vxTableReset vxJoinReset} vxClose} vxSelect Text1_Change Form_Unload< Cancel FileMenu_Click OpenAircraft_Click OpenTypes_Click TypeReturn AirtypesDbf AirTypesNtx TypeStartk VXFORM0 VXFORM2 Visible ThenCancel$ BrowseTypes1 OpenCust_Click AircustDbf Aircust1Ntx Aircust2Ntx Aircust3Ntx AirstateDbf Airstat1Ntx. Airstat2NtxU AirbuyerDbf< Airbuy1Ntxd Airbuy2Ntxh VX_GRAY AircraftDbfs Aircraf1Ntx Aircraf2Ntx VX_GREEN there active1 browseC windows table allow BrowseCust AirCust LinkBuyToSell_Click StatesOpen AircraftOpen TypesOpen brokerage customers fileB BrowseAir BuyerOpent BofExprY EofExpr6 VX_EXPR BuyReturnb BuyerReturn LinkSellToBuy_Click Demonstration setting visual relationships AircraftReturn TestCreate_Click CustFile[ FileStruc NumFields Fld01 Fld02 Fld03[ Fld04 Fld05 vxCreate TypeFiler TypeDbfN vxCreateNtx TypeNtx vxAppendFrom NewRet vxCreateDbf PackFiles_Click vxPackR TestCopy_Click NtxExpr MaintMenu_Click vxNtxExpr3 vxCopyStruc TestDataCopy_Click vxCopy vxDeleteRange DbfName& vxDbfName StartRec EndRec vxEmpty vxExactOnI vxSeek vxFoundr vxExactOff FileStruc_Click VXFORM7d vxNtxDeselect NtxName vxNtxName vxDeleteRec$ vxRecallq vxReindex vxZap vxSeekSoft? vxAreaDbf Form_Painth vxFormGray vxFormFrame vxCtlGrayReset4 every database OpenCust OpenAircraft LinkBuyToSell LinkSellToBuy PackFiles TestCreateO TestDataCopy TestCopy OpenTypes which updates CanClose VXFORM3 VXFORM4, VXFORM5 VXFORM6 Form2Active Form3Active Form4Active Form5Active Form6Active Form7Active Form_GotFocusA disabling vxUnlock ExitCode_Click The master form VXFORM1 is unloaded. The Form_Unload procedure does then final cleanup.a Form_Unload This routine is activated from either the Exit menu item on VXFORM1 or by selecting the Close item from the system menu. We MUST test the vxCloseAll result in case there are any active browse windows- that require closure before we cani terminate the application If the close operation is successful, any open databases FOR THIS TASK are closed (which updates the database header information) and all attached memory objects (Tables and Joins)s are released. if any of our other forms are active, we cannot close this form and exit the app Sub forms must be closed first redraw top level form NOTE: we cannot use the FORM.Visible property toy check if any forms are active because as soon asn we reference a form, it gets loaded - and our app will stall with No Database messages because as soons as the form is loaded, the database attached to thatt form is referencedd redraw top level form reset system disabled color OpenTypes_Click in VXBMOD.BAS start browse table( in module file VXBMOD.BAS OpenCust_Click open brokerage customers file \vb\vxbtest\aircust.dbf" Error Opening aircust.dbf. Aborting. \vb\vxbtest\aircust1.ntx \vb\vxbtest\aircust2.ntx \vb\vxbtest\aircust3.ntx Declare Customer Tablen a_code a_name a_city State" a_state" Res Phone" a_phoneres Bus Phone" a_phonebus open state abbreviations file in VXBMOD.BAS start browse tablee in module VXMOD.BAS OpenAircraft_Click both routines in VXBMOD.BAS LinkBuyToSell_Click Demonstration of setting up visual relationshipsh with the vxJoin command. What we have is a file of buyers categorized by type of aircraft they are interested in. What we are going to do is display a browse table ofe these buyer records and link any buyer record tod another browse table of aircraft that match the the buyer aircraft type field.e Conversely, the LinkSellToBuy proc does the opposite. It. links the aircraft with all prospective buyers. open file that will control the joinj \vb\vxbtest\airbuyer.dbf \vb\vxbtest\airbuy2.ntx" this index is on aircraft typet define table to show data we are interested ind b_cat" Description" left(b_desc,20)" b_low" b_high Customer b_code now open secondary file and define its tablea \vb\vxbtest\aircraft.dbf Error Opening aircraft.dbf. Aborting." \vb\vxbtest\aircraf2.ntx on type c_cat" c_code Price" c_price" c_year c_ttsn reselect the master file and set up the joinj b_cat" Possible Sales# this joins the Aircraft file using the index selected for it to the buyer file. The "b_cat" param is the field we will use as a key into the aircraft file and the VX_FIELD item tells vxBase that it is a field and not an expression. The last item in the call is a title for the join window. disable menu items that might affect our displayp now set up and execute the browse. The JOIN menu item ism automatically enabled.l Buyer Details" when we return from the browse we can ignore anything vxBase sent back to us in the BuyerReturn param we could get fancy and get the customer record if the use hit enter and then display or edit it. Do whatever you like.i re-enable menu itemst LinkSellToBuy_Click Browse the aircraft for sale file and join to potential buyers. See a more detailed explanantion of visual relationships in the LinkBuyToSell ProcP open file that will control the join- \vb\vxbtest\aircraft.dbf Error Opening aircraft.dbf. Aborting." \vb\vxbtest\aircraf2.ntx on type define table to show data we are interested inF c_cat" Description" left(c_desc,20)" c_code Price" c_price" c_year c_ttsn now open secondary file and define its table \vb\vxbtest\airbuyer.dbf Error Opening airbuyer.dbf. Aborting." \vb\vxbtest\airbuy2.ntx" b_cat" b_low" b_high Customer b_code reselect the master file and set up the join c_cat" Possible Buyers"# this joins the buyer file using the index selected for it to the aircraft file. The "c_cat" param is the field we will use as a key into the buyer file and the VX_FIELDd item tells vxBase that it is a field and not an expression. The last item in the call is a title for the join window. disable menu itemst now set up and execute the browse. The JOIN menu item is- automatically enabled. Aircraft Record Display" when we return from the browse we can ignore anything vxBase sent back to us in the BuyerReturn param re-enable menu itemst TestCreate_Click 1234567890123456 (ruler to help alignment) CATEGORY C 3 0 CATNAME C 15 0 our field length for the second field is shorterr than the original file so when we appendfrom belowe this field should be truncated and will show as such in the browseo \vb\vxbtest\typefile.dbf Error in database creation \vb\vxbtest\typefile.dbf index create opens and selects new index ande returns the index select area. Zero (FALSE) is returned if there was an error \vb\vxbtest\typefile.ntx category Error in index create" \vb\vxbtest\airtypes.dbf Error in append from New File \vb\vxbtest\typefile.dbf \vb\vxbtest\typefile.ntx PackFiles_Click removes logically deleted records and reindexes \vb\vxbtest\airtypes.dbf airtypes in use! \vb\vxbtest\airtypes.dbf \vb\vxbtest\airtypes.ntx \vb\vxbtest\aircust.dbf" aircust in use!" \vb\vxbtest\aircust.dbf" \vb\vxbtest\aircust1.ntx \vb\vxbtest\aircust2.ntx \vb\vxbtest\aircust3.ntx \vb\vxbtest\airbuyer.dbf airbuyer in use! \vb\vxbtest\airbuyer.dbf \vb\vxbtest\airbuy1.ntx" \vb\vxbtest\airbuy2.ntx" \vb\vxbtest\aircraft.dbf aircraft in use! \vb\vxbtest\aircraft.dbf \vb\vxbtest\aircraf1.ntx \vb\vxbtest\aircraf2.ntx TestCopy_Click disable items that would be affected by closure of airtypes filef \vb\vxbtest\airtypes.dbf \vb\vxbtest\airtypes.ntx \vb\vxbtest\testcopy.dbf Error in database copy struc \vb\vxbtest\testcopy.dbf index create opens and selects new index ande returns the index select area. Zero (FALSE) is returned if there was an error \vb\vxbtest\testcopy.ntx Error in index create" \vb\vxbtest\airtypes.dbf Error in append from New File \vb\vxbtest\testcopy.dbf \vb\vxbtest\testcopy.ntx TestDataCopy_Click \vb\vxbtest\airtypes.dbf \vb\vxbtest\airtypes.ntx \vb\vxbtest\testdata.dbf Error in database copy \vb\vxbtest\testdata.dbf Test delete range Error in DeleteRange index create opens and selects new index and returns the index select area. Zero (FALSE) is returned if there was an error \vb\vxbtest\testdata.ntx Error in index create" test ntx name function" \vb\vxbtest\testdata.dbf Kill "\vb\vxbtest\testdata.ntx" FileStruc_Click disable items that would be affected by closing of aircust file Form_Paint Form_Click test for active forms and set menu items accordingly. We do this here as well as when we start up our forms because some functions allow otherr functions to be active and when one or the other is closed and menu items are re-enabled, then we mess up our menur disabling for the ones left open.